<template>
	<view class="center">
		<cu-custom :bgColor="globalColor" :isBack="false">
		    <block slot="content">我的</block>
		</cu-custom>
		<!-- <view class="center_top" style="background: white;">
			<view class="mask"></view>
		</view> -->
		<view class="center_box_bg">
			<!-- <view class="profily">
				<view class="base">
					<view class="profily_header" :style="{ backgroundImage:'url('+avatarUrl+')'}"></view>
					<text>永久免费去水印</text>
				</view>
				<view class="order_status">
					<view class="status" v-for="(item,index) in status" :key="index" @click="page(index)">
						<image class="icon" :src="item.url" mode="aspectFill"></image>
						<text>{{item.name}}</text>
					</view>
				</view>
			</view> -->
		<!-- 	<view class="baiban">

			</view> -->
			<view class="center_menu">
				<view class="menu_item" v-for="(item,index) in menus" :key="index" @click="toPage(index)">
					<image :src="item.icon" mode="aspectFill"></image>
					<text v-if="index == 0">{{author}}</text>
				</view>
				<!-- <view class="menu_item custom-menu_item" @click="changeChecked">
					<view>是否开启自动识别链接</view>
						<view>
							<switch :checked="autoCopy"></switch>
						</view>
				</view> -->
				<view class="menu_item" @click="page(1)">
					<view>解析记录</view>
				</view>
			</view>
			<view class=" flex flex-direction" style="margin: 10px 0;">
				<button class="cu-btn bg-blue lg" open-type="contact">在线客服</button>
			</view>
			
		</view>
		<view>
			<ad v-if="showAd" :unit-id="myAd" ad-type="video" ad-theme="white"></ad>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				nickName:getApp().globalData.nickName,
				avatarUrl:getApp().globalData.headUrl,
				author:getApp().globalData.author,
				autoCopy:getApp().globalData.autoCopy,
				autoDownload:getApp().globalData.autoDownload,
				myAd:getApp().globalData.myAd,
				uid:getApp().globalData.uid,
				globalColor: getApp().globalData.globalColor,
				showAd:false,
				status: [{
						key: 1,
						name: '教程',
						url: '../../static/img/learn.png'
					},
					{
						key: 2,
						name: '解析记录',
						url: '../../static/img/record.png'
					},
					{
						key: 3,
						name: '小程序码',
						url: '../../static/img/qrcode.png'
					}/* ,
					{
						key: 4,
						name: '赞赏作者',
						url: '../../static/img/prize-1.png'
					} */
				],
				menus: [{
						name: '联系作者',
						icon: '../../static/img/concat.png',
						key: 1,
					}

				]
			};
		},
		onLoad() {
			this.myAd = getApp().globalData.myAd
			this.showAd = true
			var cacheCopy = uni.getStorageSync("autoCopy");
			if(cacheCopy) {
				this.autoCopy = cacheCopy
			}
		},
		onShow() {
			this.nickName = getApp().globalData.nickName
			this.avatarUrl = getApp().globalData.headUrl
		},
		onShareAppMessage(res) {
			return {
			  title: '抖音、快手、皮皮虾短视频一键去水印,去水印还能这么简单,图片也可以去水印哟',
			  path: '/pages/index/index',
			  imageUrl: 'http://parse-video-server.oss-cn-hangzhou.aliyuncs.com/share.png'
			}
		},
		onShareTimeline: () => {
		  return {
		    title: getApp().globalData.shareTitle,
		    query: "/pages/index/index",
		    imageUrl:getApp().globalData.sharePic
		  }
		},
		methods: {
			changeChecked() {
				this.autoCopy = !this.autoCopy;
				getApp().globalData.autoCopy = this.autoCopy;
				uni.setStorageSync('autoCopy',this.autoCopy)
			},
			toPage(type) {
				console.log(type)
				if(type == 0) {
					uni.setClipboardData({
						data:getApp().globalData.author,
						success: (res) => {
							uni.showModal({
								content:'已复制作者微信'
							})
						}
					})
				}else {
					if(this.autoDownload) {
						this.autoDownload = false
						getApp().globalData.autoDownload = false
						uni.setStorageSync('autoDownload',false)
						uni.showModal({
							content:'自动下载功能已经关闭，解析成功后需要手动点击保存到相册'
						})
					}else {
						this.autoDownload = true
						getApp().globalData.autoDownload = true
						uni.setStorageSync('autoDownload',true)
						uni.showModal({
							content:'自动下载功能已经开启，解析成功后系统自动保存到相册'
						})
					}
				}
			},
			page(type) {
				if(type == 0) {
					uni.navigateTo({
						url:'../parse/parse?conId=3'
					})
				}else if(type == 1) {
					uni.navigateTo({
						url:'../list/list'
					})
				}else if(type == 2) {
					var that = this;
					uni.previewImage({
						urls: [getApp().globalData.shareImg],
						longPressActions: {
							itemList: ['发送给朋友', '保存图片', '收藏']
						}
					});
				}else {
					var that = this;
					uni.previewImage({
						urls: [getApp().globalData.prizeImg],
						longPressActions: {
							itemList: ['发送给朋友', '保存图片', '收藏']
						}
					});
				}
			}
		},
		computed: {

		}
	}
</script>

<style lang="scss">
	page {
		height: 100%;
	}

	.profily,
	.profily_header {
		border-radius: 8px;
	}

	.center {
		height: 100%;

		&_top {
			height: 10%;
			//background: url('../../static/fumou-center-template/header.jpg') no-repeat 0% 50%;
			background-size: cover;

			// background: #E6E6E6;
			.mask {
				background: white;
				height: 100%;
			}
		}

		&_box_bg {
			background: #F9F9F9;
			position: relative;

			.profily {
				// position: absolute;
				width: 100%;
				// border:1px solid #F7F7F7;
				margin: 0 auto;
				// top: -100upx;
				background: #FEFEFE;
				padding: 35upx;
				box-sizing: border-box;
				box-shadow: 0px 2px 5px #EDEDED;
			}
		}
	}

	.base {
		display: flex;
		align-items: center;
		border-bottom: 2px solid #F6F6F6;
		padding-bottom: 35upx;
		position: relative;
		.profily_header {
			height: 120upx;
			width: 120upx;
			background-image: url('../../static/fumou-center-template/header.jpg');
			background-size: 100%;
		}

		text {
			margin-left: 20px;
			font-size: 40rpx;
			font-weight: bold;
		}
		
		image{
			position: absolute;
			height: 40upx;
			width: 40upx;
			right: 0px;
			top:0px;
		}
	}

	.order_status {
		display: flex;
		justify-content: space-between;
		margin-top: 35upx;

		.status {
			width: 140upx;
			font-size: 24upx;
			text-align: center;
			letter-spacing: .5px;
			display: flex;
			flex-direction: column;
			.icon {
				width: 50upx;
				height: 50upx;
				margin: 0 auto;
				margin-bottom: 5px;
				
			}
		}
	}

	.baiban {
		background: #FEFEFE;
		height: 300upx;
	}

	.center_menu {
		width: 100%;
		display: inline-block;
		margin-top: 10px;
		border-radius: 8px;
		overflow: hidden;
		.menu_item {
			font-size: 28upx;
			letter-spacing: 1px;
			padding: 14px 5%;
			background: #FEFEFE;
			overflow: hidden;
			box-sizing: border-box;
			display: flex;
			align-items: center;
			position: relative;
			border-bottom: 1px solid #EFEFEF;

			&:hover {
				background: #F6F6F6 !important;
			}

			&::after {
				content: '';
				width: 30upx;
				height: 30upx;
				position: absolute;
				right: 5%;
				background: url('../../static/fumou-center-template/right.png') no-repeat;
				background-size: 100%;
			}

			text:nth-of-type(1) {
				margin-left: 10px;
			}

			image {
				width: 40upx;
				height: 40upx;
			}

			&:nth-of-type(4) {
				margin-top: 10px;
			}
		}
		.custom-menu_item{
			justify-content: space-between;
			&::after{
				display: none;
			}
		}
	}
	.center_box_bg{
		padding: 0 10px;
	}
</style>

